--[[ *  随机驱散buff
-- *  [0] buff类型      1-增益buff，2-负面buff
-- *  [1] 数量
]]
---@class BuffEffect37 : BaseBuffEffect
BuffEffect37 = ClientFight.CreateClass("BuffEffect37", ClientFight.BaseBuffEffect)
local t = BuffEffect37
---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...}
    local selected = {};
    local fighter = buff.target;
    local effectVals = buff.buffBean.f_BuffEffectValue;

    for id, tmpBuff in pairs(fighter.buffs) do
        if (tmpBuff.buffBean.f_BuffType == effectVals[1]) then
            table.insert(selected, tmpBuff);
        end
    end
    if (table.getn(selected) == 0) then
        SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]%s触发%s随机驱散buff 没有可驱散buff ",
                fight.frame, fighter.fighterId, buff.modelId
        ));
    end

    for i = 1, effectVals[2] do
        if (table.getn(selected) == 0) then
            break ;
        end
        local delete = table.remove(selected, (fight:random(table.getn(selected))));
        BuffManager.removeFighterBuff(fight, fighter, delete, true, parameters);
        SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]%s触发%s随机驱散buff 移除%s ",
                fight.frame, fighter.fighterId, buff.modelId, delete.modelId
        ));
    end
    return ClientFight.BaseBuffEffect.action(self, fight, buff, parameters);
end

t.New()